<div class="bg-light lter b-b wrapper-md">
  <h1 class="m-n font-thin h3">频道管理</h1>
</div>



<div class="wrapper-md"  >
<div class="panel panel-default">
  <div ng-controller="infoEditCtrl">
    <div class="row">
    
      <div class="col-sm-12" >
        <form name="form-contact" ng-submit="processForm()" class="form-horizontal">

            <div class="panel-heading">
              <span class="h4">

<button class="btn btn-default btn-sm " ng-click="goBack()"><i class="fa fa-mail-reply fa-lg"></i>&nbsp; 返回</button>


              </span>
            </div>
            <div class="panel-body">
            
=
 <div class="panel-heading">
              <span class="h4" style="color: blue;">分集信息</span>
            </div>

<div class="form-group">
    <label class="col-sm-1 control-label">分集序号</label>
    <div class="col-sm-5">
 <input type="text" class="form-control" placeholder="分集序号" ng-model="contact.DiversityId" required >
    </div>

    <label  class="col-sm-1 control-label">分集名称</label>
    <div class="col-sm-5">
      <input type="text" class="form-control" placeholder="分集名称" ng-model="contact.DiversityTitle" required >
    </div>
  </div>
  <div class="line line-dashed b-b line-lg pull-in"></div>



<div class="form-group">
    <label class="col-sm-1 control-label">排序</label>
    <div class="col-sm-5">
 <input type="number" class="form-control"  min="0" max="99"  placeholder="排序" ng-model="contact.DiversityPlayCount" required >
    </div>
  </div>
  <div class="line line-dashed b-b line-lg pull-in"></div>
              <div class="form-group">
                 <label class="col-sm-1 control-label">介绍</label>  
               <div class="col-sm-10">
                   <textarea class="form-control" ng-model="contact.DiversityIntroduction" rows="6" placeholder="介绍"></textarea>
               </div>
                </div>
  <div class="line line-dashed b-b line-lg pull-in"></div>

            </div>

                 <div class="panel-body">

           




 
  <div class="line line-dashed b-b line-lg pull-in"></div>





  <!--隐藏字段-->
<input type="hidden"  ng-model="contact.Id"  >
<input type="hidden"  ng-model="contact.DiversityUuid"  >
<input type="hidden"  ng-model="contact.ProgramId"  >

<input type="hidden"  ng-model="contact.AdderId"  >
<input type="hidden"  ng-model="contact.AdderName"  >
<input type="hidden"  ng-model="contact.AddTime"  >
<input type="hidden"  ng-model="contact.UpdaterId"  >
<input type="hidden"  ng-model="contact.UpdaterName"  >
<input type="hidden"  ng-model="contact.UpdateTime"  >
<input type="hidden"  ng-model="contact.DelFlag" ng-init="contact.DelFlag='0'"  >
    <!--隐藏字段-->
 






            </div>


            <footer class="panel-footer text-right bg-light lter">
              <button type="submit" class="btn btn-success">提交</button>
            </footer>
          </div>
        </form>
      </div>
    </div>
   
</div>
</div>




</div>


<!--angularjs-->
<script type="text/javascript">
  'use strict';
app.controller('infoEditCtrl', function ($scope, $state, $stateParams,$http,$window) {

    



//返回按钮：开始
$scope.$window = $window;
    $scope.goBack = function() {
      $window.history.back();
    };
//返回按钮：结束

         var infoId = $stateParams.deversityId;
         var programId = $stateParams.programId;
          console.log('获取路由参数deversityId：'+infoId);
          console.log('获取路由参数programId：'+programId);

         //如果infoId不为空，查询详情：开始
         if('' != infoId ){

         var getInfoUrl = API_URL+"program_diversity?query=delflag:0,Id:"+infoId;    

         $http.get(getInfoUrl).success(function (response) {
         
          var obj = response[0];
        
          $scope.contact = obj;

      });
  }
//如果infoId不为空，查询详情：结束




  //表单提交开始
$scope.processForm= function (){
 
  //1.参数处理

//发起POST请求
var postInfoUrl = API_URL+"program_diversity";
var formData =  $scope.contact;

  //1.参数处理
    formData.AddTime = getNowDBFormatDate();
    formData.UpdateTime = getNowDBFormatDate();
    formData.AdderId = 1;
    formData.AdderName = '1';
    formData.UpdaterId = 1;
    formData.UpdaterName = '1';
    formData.DiversityUuid='';

    console.log(JSON.stringify(formData));
  if("undefined"!=typeof(formData.Id)){

          $.ajax({  
                  async : false, //是否异步  
                  cache : false, //是否使用缓存  
                  type : 'put', //请求方式,post  
                  dataType : "json", //数据传输格式  
                  url : postInfoUrl+'/'+infoId, //请求链接  
                  data: JSON.stringify(formData),
                  error : function() {  
                      console.log('亲，网络有点不给力呀！');  
                  },  
                  success : function(data) { 
                  top.layer.msg('保存成功', {icon: 6});
                  //2.成功跳转页面
                  $state.go('app.movie.diversity', {programId: programId});
                  }  
             }); 
              }else{

           $.ajax( {  
                  async : false, //是否异步  
                  cache : false, //是否使用缓存  
                  type : 'post', //请求方式,post  
                  dataType : "json", //数据传输格式  
                  url : postInfoUrl, //请求链接  
                  data: JSON.stringify(formData),
                  error : function() {  
                      console.log('亲，网络有点不给力呀！');  
                  },  
                  success : function(data) { 

                    top.layer.msg('保存成功', {icon: 6});
                 //2.成功跳转页面
                 $state.go('app.movie.diversity', {programId: programId});
                  }  
             }); 

  }
}
 //表单提交结束
 

});
</script>
<!--angularjs-->










